home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Darts(Clock).dxr / Internal_2_throw darts.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  6.7 KB  |  221 lines

  1. property spriteNum, pDart, pLoc, pDistanceFromBoard, pBoardHeightFromGround, pPower, pDeterMinePower, pGravity, pair, pDiffer, pScale, pHeightOfDart, pOgHeight, pOgWidth, pFollow, hateV, hateH, myOloc, myOh, myOv, myOr
  2. global gDartCount, gEnableGrab, gEnablethrow, gIB, gBscreen, gDartPoint, gCRBox, gTargets, gDartButtons, gRound, gCurrentScore, gRoundScore, gCSBox, gRSBox, gDartScore, gCurrentSector, gGotDouble, pootimer, gDartList, pseudoList
  3.  
  4. on beginSprite me
  5.   gDartList.add(spriteNum)
  6.   myOloc = sprite(spriteNum).loc
  7.   myOh = sprite(spriteNum).height
  8.   myOv = sprite(spriteNum).width
  9.   myOr = sprite(spriteNum).rotation
  10.   sprite(spriteNum).ink = 8
  11.   sprite(spriteNum).member.alphaThreshold = 0
  12. end
  13.  
  14. on cleanUp me
  15.   sprite(spriteNum).loc = myOloc
  16.   sprite(spriteNum).height = myOh
  17.   sprite(spriteNum).width = myOv
  18.   sprite(spriteNum).rotation = myOr
  19. end
  20.  
  21. on init me
  22.   pDart = sprite(spriteNum)
  23.   pDistanceFromBoard = 96
  24.   pBoardHeightFromGround = 68
  25.   pGravity = 0.59999999999999998
  26.   pHeightOfDart = 28
  27.   pOgHeight = pDart.height
  28.   pOgWidth = pDart.width
  29.   pFollow = timeout("follow").new(1, #followMouse, me)
  30.   pair = VOID
  31. end
  32.  
  33. on followMouse me
  34.   if (the mouseH >= 0) and (the mouseH <= (the stage).rect.width) and ((the mouseV >= 250) and (the mouseV <= (the stage).rect.height)) then
  35.     pDart.loc = the mouseLoc
  36.   else
  37.     pDart.locH = the mouseH
  38.   end if
  39. end
  40.  
  41. on mouseDown me
  42.   if voidp(pair) and (pDistanceFromBoard > 0) then
  43.     gEnablethrow = 1
  44.     pFollow.forget()
  45.     pLoc = []
  46.     pLoc[1] = pDart.locH
  47.     pLoc[2] = pDart.locV
  48.     pDistanceFromBoard = 96
  49.     pHeightOfDart = 28
  50.     pDeterMinePower = timeout("power" & string(spriteNum)).new(5, #buildPower, me)
  51.   end if
  52. end
  53.  
  54. on mouseUp me
  55.   if gEnablethrow and (pDistanceFromBoard > 0) then
  56.     puppetSound(4, member("throw dart"))
  57.     gEnablethrow = 0
  58.     hateH = the mouseH
  59.     hateV = the mouseV
  60.     pDartsCount = pDartsCount + 1
  61.     pDeterMinePower.forget()
  62.     buildPower()
  63.     pair = timeout("pAir" & string(spriteNum)).new(5, #thrown, me)
  64.   end if
  65. end
  66.  
  67. on mouseUpOutSide me
  68.   if gEnablethrow and (pDistanceFromBoard > 0) then
  69.     puppetSound(4, member("throw dart"))
  70.     gEnablethrow = 0
  71.     hateH = the mouseH
  72.     hateV = the mouseV
  73.     pDartsCount = pDartsCount + 1
  74.     pDeterMinePower.forget()
  75.     buildPower()
  76.     pair = timeout("pAir" & string(spriteNum)).new(10, #thrown, me)
  77.   end if
  78. end
  79.  
  80. on buildPower me
  81.   pPower = -((float(hateV) - pLoc[2]) * 0.17999999999999999) * 0.72999999999999998
  82.   pDiffer = -((float(hateH) - pLoc[1]) * 0.17999999999999999) * 0.72999999999999998
  83.   if pPower < 10 then
  84.     pPower = 10
  85.   end if
  86.   if pPower > 22 then
  87.     pPower = 22
  88.   end if
  89. end
  90.  
  91. on thrown me
  92.   pDart.height = pDart.height - 3.54999999999999982
  93.   pDart.width = pDart.width - 3.54999999999999982
  94.   pDart.rotation = pDart.rotation + (pPower * 1.30000000000000004)
  95.   pPower = pPower - pGravity
  96.   pDistanceFromBoard = float(pDistanceFromBoard) - 2.5
  97.   pHeightOfDart = pHeightOfDart + pPower
  98.   pLoc[2] = pLoc[2] - pPower
  99.   pLoc[1] = pLoc[1] - pDiffer
  100.   pDart.locV = pLoc[2]
  101.   pDart.locH = pLoc[1]
  102.   pLoc[2] = pDart.locV
  103.   pLoc[1] = pDart.locH
  104.   if pDistanceFromBoard <= 0 then
  105.     if pDart.locV < 440 then
  106.       og = [290.0, 220.0]
  107.       pd = [pDart.locH.float, pDart.locV.float]
  108.       vec = [pd[1] - og[1], pd[2] - og[2]]
  109.       veclen = sqrt((vec[1] * vec[1]) + (vec[2] * vec[2]))
  110.       if veclen > 190 then
  111.         puppetSound(4, member("dart hit"))
  112.       else
  113.         puppetSound(4, member("dart hit 2"))
  114.       end if
  115.     else
  116.       puppetSound(4, member("hit floor"))
  117.     end if
  118.     pair.forget()
  119.     gDartPoint.loc = pDart.loc
  120.     repeat with i = 1 to gTargets.count
  121.       updateStage()
  122.       if not gGotDouble then
  123.         if gDartPoint.intersects(gTargets[i]) then
  124.           if sprite(gTargets[i]).pMultiply = 2 then
  125.             gGotDouble = 1
  126.             member("current sector").text = string(gCurrentSector)
  127.             pseudoList = []
  128.             repeat with i = 1 to gTargets.count
  129.               if sprite(gTargets[i]).pSector = gCurrentSector then
  130.                 pseudoList.add(gTargets[i])
  131.               end if
  132.               if pseudoList.count = 4 then
  133.                 blinkLikeTheDickens()
  134.               end if
  135.             end repeat
  136.           end if
  137.         end if
  138.         next repeat
  139.       end if
  140.       if gGotDouble then
  141.         if sprite(gTargets[i]).pSector = gCurrentSector then
  142.           if gDartPoint.intersects(gTargets[i]) then
  143.             if sprite(gTargets[i]).pSector = gCurrentSector then
  144.               gCurrentScore = gCurrentScore + sprite(gTargets[i]).returnPoints()
  145.               gCSBox.text = string(gCurrentScore)
  146.               gCurrentSector = gCurrentSector + 1
  147.               gRoundScore[gRound] = string(gRoundScore[gRound] + sprite(gTargets[i]).returnPoints())
  148.               gRSBox[gRound].text = string(gRoundScore[gRound])
  149.               gDartScore[gDartCount] = string(sprite(gTargets[i]).returnPoints())
  150.               if gRound <= 20 then
  151.                 pseudoList = []
  152.                 repeat with i = 1 to gTargets.count
  153.                   if sprite(gTargets[i]).pSector = gCurrentSector then
  154.                     pseudoList.add(gTargets[i])
  155.                   end if
  156.                   if pseudoList.count = 4 then
  157.                     blinkLikeTheDickens()
  158.                   end if
  159.                 end repeat
  160.               end if
  161.               if gCurrentSector = 21 then
  162.                 pootimer = timeout("yyy").new(1000, #gameEnd, me)
  163.                 next repeat
  164.               end if
  165.               member("current sector").text = string(gCurrentSector)
  166.             end if
  167.           end if
  168.         end if
  169.       end if
  170.     end repeat
  171.     member("dart" && string(gDartCount)).text = string(gDartScore[gDartCount])
  172.     gEnableGrab = 1
  173.     if gDartCount = 3 then
  174.       gRSBox[gRound].text = string(gRoundScore[gRound])
  175.       if gCurrentSector <> 21 then
  176.         gBscreen = timeout("bscreen").new(800, #bscreen, me)
  177.       end if
  178.     end if
  179.   end if
  180. end
  181.  
  182. on bscreen me
  183.   gBscreen.forget()
  184.   gDartCount = 0
  185.   gRound = gRound + 1
  186.   gDartScore = [0, 0, 0]
  187.   gCRBox.text = string(gRound)
  188.   repeat with i = 1 to 3
  189.     member("dart" && string(i)).text = "0"
  190.   end repeat
  191.   repeat with i = 1 to gDartList.count
  192.     sprite(gDartList[i]).cleanUp()
  193.   end repeat
  194.   repeat with i = 1 to gDartButtons.count
  195.     sprite(gDartButtons[i]).visible = 1
  196.   end repeat
  197.   repeat with i = 1 to gIB.count
  198.     sprite(gIB[i]).cleanUp()
  199.   end repeat
  200.   if gRound <= 20 then
  201.     if member("Current Sector").text <> "Double" then
  202.       pseudoList = []
  203.       repeat with i = 1 to gTargets.count
  204.         if sprite(gTargets[i]).pSector = gCurrentSector then
  205.           pseudoList.add(gTargets[i])
  206.         end if
  207.         if pseudoList.count = 4 then
  208.           blinkLikeTheDickens()
  209.         end if
  210.       end repeat
  211.     end if
  212.   end if
  213.   if gRound > 20 then
  214.     gameEnd()
  215.   end if
  216. end
  217.  
  218. on gameEnd me
  219.   go("game over")
  220. end
  221.